'''
Created on Dec 29, 2010

@author: Nican
'''

import pygame
import Octorotor
import threading

class OctoThread(threading.Thread):
    '''
    classdocs
    '''


    def __init__(self, port, baudRate):
        threading.Thread.__init__(self)
        
        '''
        Constructor
        '''
        self.comPort = port
        self.baudRate = baudRate
        self.octorotor = None
        self.Active = True
        
        
    def run (self):
        
        self.octorotor = Octorotor.Octorotor(self.comPort, self.baudRate)
         
        while self.Active == True:
            self.octorotorThink()
        
        self.endOctorotor()
        
    def octorotorThink(self):
        self.octorotor.think()
        
        pygame.event.poll()
    
    def endOctorotor(self):
        self.Active = False
        self.octorotor.Remove()
        
        